import requests
import json
import time

appkey = 'dingxokazzgqz4k5ypbb'
appsecret = 'SP8sN9GK77Dmvuv_rmZLcZ8nbbuLX7DtHSjepJ4RaUXIxvdzvMPg0pF185_LPt0x'

api_url = "https://oapi.dingtalk.com/gettoken?appkey=%s&appsecret=%s"%(appkey,appsecret)

def get_token():
    res = requests.get(api_url)
    if res.status_code == 200:
        str_res = res.text
        token = (json.loads(str_res)).get('access_token')
        return token

token = get_token()

print(token)

mydate = "2020-11-10"
dt_start = '%s 00:00:00' % mydate
dt_end = '%s 23:59:59' % mydate
ts_start = int(time.mktime(time.strptime(dt_start, "%Y-%m-%d %H:%M:%S"))) * 1000
ts_end = int(time.mktime(time.strptime(dt_end, "%Y-%m-%d %H:%M:%S"))) * 1000

print(ts_start)

print(ts_end)

# res = requests.post('https://oapi.dingtalk.com/attendance/list?access_token=%s' % token,json ={'access_token':token,'workDateFrom':'%s 00:00:00' % mydate,'workDateTo':'%s 10:00:00' % mydate,'userIdList':str(x),'offset':0,'limit':50})



